FrameLib
2.0
DSP processing with frames of arbitrary timing and length
FrameLib_Global.h
Go to the documentation of this file.
1
2
#ifndef FRAMELIB_GLOBAL_H
3
#define FRAMELIB_GLOBAL_H
4
5
#include "
FrameLib_Types.h
"
6
#include "
FrameLib_Errors.h
"
7
#include "
FrameLib_Memory.h
"
8
#include "
FrameLib_ProcessingQueue.h
"
9
#include "
FrameLib_Threading.h
"
10
11
#include <memory>
12
#include <vector>
13
28
class
FrameLib_Global
:
public
FrameLib_ErrorReporter
29
{
30
31
friend
class
FrameLib_Context
;
32
33
private
:
34
35
template
<
class
T>
class
PointerSet
36
{
37
// A simple countable pointer with a reference address
38
39
struct
CountablePointer
40
{
41
CountablePointer(T*
object
,
void
*reference) : mObject(object), mReference(reference), mCount(1) {}
42
43
std::unique_ptr<T> mObject;
44
void
*mReference;
45
long
mCount;
46
};
47
48
public
:
49
50
// Add, find or release an object by reference address
51
52
void
add(T *
object
,
void
*reference);
53
T *find(
void
*reference);
54
void
release
(
void
*reference);
55
56
private
:
57
58
// Internal Pointers
59
60
std::vector<CountablePointer> mPointers;
61
};
62
63
public
:
64
76
static
FrameLib_Global
*
get
(
FrameLib_Global
**global,
FrameLib_ErrorReporter::HostNotifier
*notifier =
nullptr
);
77
87
static
void
release
(
FrameLib_Global
**global);
88
89
private
:
90
91
// Constructor / Destructor
92
93
FrameLib_Global
(
FrameLib_ErrorReporter::HostNotifier
*notifier) :
FrameLib_ErrorReporter
(notifier), mAllocator(*this), mCount(0) {}
94
~
FrameLib_Global
() {};
95
96
// Non-copyable
97
98
FrameLib_Global
(
const
FrameLib_Global
&) =
delete
;
99
FrameLib_Global
& operator=(
const
FrameLib_Global
&) =
delete
;
100
101
// Methods to retrieve common objects
102
103
FrameLib_LocalAllocator
*getAllocator(
void
*reference);
104
FrameLib_ProcessingQueue
*getProcessingQueue(
void
*reference);
105
106
// Methods to release common objects
107
108
void
releaseAllocator(
void
*reference);
109
void
releaseProcessingQueue(
void
*reference);
110
111
// Reference Counting / Auto-deletion
112
113
void
increment();
114
FrameLib_Global
*decrement();
115
116
// Member Variables
117
118
// Global Memory Allocator
119
120
FrameLib_GlobalAllocator
mAllocator;
121
122
// Context-specific Resources
123
124
PointerSet<FrameLib_LocalAllocator> mLocalAllocators;
125
PointerSet<FrameLib_ProcessingQueue> mProcessingQueues;
126
127
// Lock and Reference Count
128
129
FrameLib_SpinLock
mLock;
130
long
mCount;
131
};
132
133
#endif
FrameLib_Global
a class for containing and managing FrameLib's global resources.
Definition:
FrameLib_Global.h:28
FrameLib_ProcessingQueue.h
FrameLib_Context
a class used to represent distinct non-connectable areas in the host environment. ...
Definition:
FrameLib_Context.h:21
FrameLib_Global::release
static void release(FrameLib_Global **global)
Definition:
FrameLib_Global.cpp:61
FrameLib_Types.h
FrameLib_SpinLock
a spinlock that can be locked, attempted or acquired.
Definition:
FrameLib_Threading.h:84
FrameLib_Errors.h
FrameLib_ErrorReporter
a class used to report errors to the host environment.
Definition:
FrameLib_Errors.h:34
FrameLib_Threading.h
FrameLib_Memory.h
FrameLib_ProcessingQueue
a minimal processing queue that is used to non-recursively process FrameLIB_DSP objects in a network...
Definition:
FrameLib_ProcessingQueue.h:30
FrameLib_GlobalAllocator
a global threadsafe memory allocator suitable for realtime usage.
Definition:
FrameLib_Memory.h:31
FrameLib_LocalAllocator
a memory allocator suitable for usage in a given FrameLib context.
Definition:
FrameLib_Memory.h:245
FrameLib_ErrorReporter::HostNotifier
a virtual struct used to supply a method for notifying the host of errors.
Definition:
FrameLib_Errors.h:47
FrameLib_Framework
FrameLib_Global.h
Generated by
1.8.13